package com.itheima.controller;

import com.itheima.R;
import com.itheima.service.CouponHistoryService;
import com.itheima.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Hakuna Matata
 * @date 2022-10-12-16:12
 */
@RestController
@RequestMapping("couponHistory")
public class CouponHistoryController {

    @Autowired
    private CouponHistoryService couponHistoryService;

    /**
     * 根据优惠券id，使用状态，订单编号分页获取领取记录
     * @param couponId
     * @param orderSn
     * @param pageNum
     * @param pageSize
     * @param userStatus
     * @return
     */
    @GetMapping("list")
    public R couponList(Integer couponId,
                        String orderSn,
                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                        Integer userStatus) {

        PageResult pageResult = couponHistoryService.couponList(couponId,orderSn,pageNum,pageSize,userStatus);
        return R.success(pageResult);
    }
}
